{% extends "base.html" %}

{% block subtitle %}
  Moderator Tools
{% endblock subtitle %}

{% block content %}
  <div ng-controller="Moderator">
    <div class="oppia-content">
      <h3>Email a user</h3>
      <div class="oppia-gallery-frame">
        <form ng-submit="submitUserEmailRequest(username)">
          <div>
            Username:
            <input type="text" ng-model="username">
          </div>
          <button type="submit">Get Email</button>
        </form>
      </div>
      <div ng-show="lastSubmittedUsername && !userEmail">
        <strong>No such user</strong>
      </div>
      <div>
        <[userEmail]>
      </div>
    </div>

    <div class="oppia-content">
      <tabset>
        <tab heading="Recent Commits" active>
          <h3>Recent Commits (all non-private explorations)</h3>
          <div when-scrolled-to-bottom="loadMoreCommits()" ng-show="allCommits.length">
            <table class="oppia-padded-table">
              <tr>
                <th>Timestamp</th>
                <th>Exploration</th>
                <th>Category</th>
                <th>Username</th>
                <th>Commit message</th>
                <th>Community-owned?</th>
              </tr>
              <tr ng-repeat="commit in allCommits track by $index">
                <td><[getDatetimeAsString(commit.last_updated)]></td>
                <td>
                  <a ng-href="<[getExplorationCreateUrl(commit.exploration_id)]>">
                    <[explorationData[commit.exploration_id].title]>
                  </a>
                </td>
                <td>
                  <[explorationData[commit.exploration_id].category]>
                </td>
                <td><[commit.username]></td>
                <td><[commit.commit_message]></td>
                <td><[commit.post_commit_community_owned]></td>
              </tr>
            </table>
          </div>
        </tab>

        <tab heading="Recent Feedback Messages">
          <h3>Recent Feedback Messages</h3>
          (Note that some of these links may be to private explorations, and thus result in authorization errors.)
          <br><br>
          <div when-scrolled-to-bottom="loadMoreFeedbackMessages()" ng-show="allFeedbackMessages.length">
            <table class="oppia-padded-table">
              <tr>
                <th>Timestamp</th>
                <th>Exploration ID</th>
                <th>Username</th>
              </tr>
              <tr ng-repeat="message in allFeedbackMessages track by $index">
                <td><[getDatetimeAsString(message.created_on)]></td>
                <td>
                  <a ng-href="<[getExplorationCreateUrl(message.exploration_id)]>">
                    <[message.exploration_id]>
                  </a>
                </td>
                <td><[message.author_username]></td>
              </tr>
            </table>
          </div>
        </tab>
      </tabset>
    </div>
  </div>
{% endblock %}

{% block footer_js %}
  {{ super() }}
  <script>
    {{ include_js_file('/moderator/Moderator.js') }}
  </script>
{% endblock footer_js %}
